package main

import "fmt"

func main() {

	//1、数组的长度是类型的一部分
	//var arr1 [3]int
	//var arr2 [4]int
	//var strArr [3]string
	//
	//fmt.Printf("arr1:%T arr2:%T strArr:%T \n", arr1, arr2, strArr)
	//2、数组的初始化
	//var arr1 [3]int
	//
	//arr1[0] = 11
	//arr1[1] = 22
	//arr1[2] = 331
	//fmt.Println(arr1)

	//var strArr [3]string
	//strArr[0] = "php"
	//strArr[1] = "python"
	//strArr[2] = "go"
	////strArr[3] = "java"	//invalid argument: index 3 out of bounds [0:3]
	//fmt.Println(strArr)

	//2、数组的初始化 第二种方法
	//var arr1 = [3]INT{11, 22, 44}
	//fmt.Println(arr1)

	//var arr1 = [3]string{"php", "python", "go"}
	//fmt.Println(arr1)

	//arr1 := [3]string{"php", "python", "go"}
	//fmt.Println(arr1)

	//3、数组的初始化 第三种方法 一般情况侠我们可以让编译器 根据初始值的个数推断数组的长度
	//var arr1 = [...]string{"php", "nodejs", "golang", "js"}
	//
	////arr1[4] = "java" //invalid argument: index 4 out of bounds [0:4]
	//fmt.Println(arr1)
	//fmt.Println(len(arr1))

	//改变数组里面的值
	//var arr1 = [...]string{"php", "nodejs", "golang", "js"}
	//arr1[0] = "phper"
	//fmt.Println(arr1)

	//4、数组的初始化 第四种方法
	//arr1 := [...]int{0: 12, 1: 11, 2: 22, 3: 33, 5: 50}
	//fmt.Println(arr1)
	//fmt.Println(len(arr1))	//6

	//5、数组的循环遍历
	//var arr1 = [3]int{23, 32, 34}
	//for i := 0; i < len(arr1); i++ {
	//	fmt.Println(arr1[i])
	//}

	//var arr1 = [...]string{"php", "nodejs", "golang", "js"}
	//for i := 0; i < len(arr1); i++ {
	//	fmt.Println(arr1[i])
	//}

	var arr1 = [...]string{"php", "nodejs", "golang", "js"}
	for k, v := range arr1 {
		fmt.Printf("key:%v value:%v\n", k, v)
	}
}
